<%@page import="java.io.FileOutputStream"%>
<%@page import="java.io.BufferedOutputStream"%>
<%@page import="java.io.OutputStream"%>
<%@page import="java.sql.Blob"%>
<%@page import="java.io.FileInputStream"%>
<%@page import="java.io.BufferedInputStream"%>
<%@page import="java.io.InputStream"%>
<%@page import="cn.jussi.dao.BaseDao"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body>
<%
	BaseDao dao = new BaseDao();
	/*String sql = "insert into users values(?,?,?,?,?,?)";
	String path = request.getSession().getServletContext().getRealPath("/")+"Resources/hkk.jpg";
	out.println(path);
	InputStream in = new BufferedInputStream(new FileInputStream(path));
	int count = dao.IUD(sql, "汉库克", "123456", "2165564", "九蛇岛", "2018-6-17", in);
	out.println(count);  */
	
	String sql = "select pho_head from users where id=?";
	Blob blob = dao.getOneColumnBlob(sql, 11);
	InputStream in = new BufferedInputStream(blob.getBinaryStream());
	String path = request.getSession().getServletContext().getRealPath("/")+"Resources/hkk1.jpg";
	OutputStream output = new BufferedOutputStream(new FileOutputStream(path));
	byte[] buffer = new byte[1024];
	int len = 0;
	while((len=in.read(buffer)) != -1){
		out.println(len);
		output.write(buffer, 0, len);
	}
	in.close();
	output.close();
%>
</body>
</html>